Noise reduction is the process of removing noise from a signal. Noise reduction techniques exists for audio and images. Noise reduction algorithms tends to alter signals to an extent that the noise in the signal reduces. Thus algotitms like this have been worked with several times the past in the feilds of signal processing, statistics, informaton theory and even machine learning.
Noise is an unwanted signal which interferes with the original message signal and corrupts the parameters of the message signal. Noise is generally a high frequency signal that is additive in nature. When a signal is transmitted through a channel (transmission media) noise is added to it and therefore the data that we receive at the receiver end is noisy. It is type of a communication impairment.
Fig: An example of noisy Signal
The best way to deal with it is by improving the SNR of the signal i.e. the signal to noise ratio
To improve the SNR, we can either increase the signal power or decrease the noise power.
Noise reduction There are many different types of filters that are used to reduce the effects of noise. Like a low pass filter which takes the lower frequencies and rejects the higher frequencies, moving average filter that takes average values at the time and the FIR filter which allows low frequency components.
Here we will be using python code to simulate the waveforms of the signals and show how noise that is added during transmission of the signal is reduced using a python script by importing the library noisereduce. Apart from that we will be using tensorflow gpu library to speedup the fft and the goussia convolution algorithms.
The noisereduce alorithm require two inputs:
Main steps of the algorithm
Written By:
Installing required python packages
!pip install tensorflow-gpu==2.0.0-beta
!pip install noisereduce
!pip install soundfile
Importing various library
import IPython
from scipy.io import wavfile as wav
from scipy import signal as sp
import noisereduce as nr
import soundfile as sf
from noisereduce.generate_noise import band_limited_noise
import matplotlib.pyplot as plt
import numpy as np
from google.colab import drive
import math as m
%matplotlib inline
drive.mount('/content/drive')
data, rate = sf.read('/content/drive/My Drive/Music/music1.wav')
data = data
IPython.display.Audio(data=data, rate=rate)
fig, ax = plt.subplots(figsize=(20,3))
ax.plot(data)
Adding noise
noise_len = 2
noise = band_limited_noise(min_freq=2000, max_freq = 12000, samples=len(data), samplerate=rate)*10
noise_clip = noise[:rate*noise_len]
audio_clip_band_limited = data + noise
fig, ax = plt.subplots(figsize=(20,3))
ax.plot(audio_clip_band_limited)
IPython.display.Audio(data=audio_clip_band_limited, rate=rate)
Lets reduce the noise
noise_reduced = nr.reduce_noise(audio_clip=audio_clip_band_limited, noise_clip=noise_clip, prop_decrease=1.0, verbose=True)
IPython.display.Audio(data=noise_reduced, rate=rate)
fig, ax = plt.subplots(figsize=(20,3))
ax.plot(noise_reduced)
Modulating the signal in FM
We took a 5Hz Sine wave message signal and a 50 Hz carrier signal to simulate
time = np.linspace(0,1,2000)
message = np.sin(2*m.pi*5*time)
carrier = np.cos(2*m.pi*50*time)
plt.subplot(3,1,1)
plt.plot(time,message)
plt.subplot(3,1,2)
plt.plot(time,carrier)
plt.show()
fmsignal = np.cos(2*m.pi*50*time-(5*(np.sin(2*m.pi*5*time)+np.sin(2*m.pi*5*time)))) #mu=5 taken
plt.subplot(3,1,1)
plt.plot(time,message)
plt.subplot(3,1,2)
plt.plot(time,carrier)
plt.subplot(313)
plt.plot(time,fmsignal)
Adding random noise
noise = np.random.normal(0,0.05,len(time))
noisysignal = fmsignal+noise
plt.subplot(2,1,1)
plt.plot(time,fmsignal)
plt.subplot(2,1,2)
plt.plot(time,noisysignal)
noisyclip = noise[:len(time)]
reducednoise = nr.reduce_noise(audio_clip=noisysignal,noise_clip=noisyclip ,verbose=False)
dem0 = np.diff(fmsignal)
dem1 = np.diff(noisysignal)
dem2 = np.diff(reducednoise)
dem0 = np.append(dem0, 0)
dem1 = np.append(dem1, 0)
dem2 = np.append(dem2, 0)
rect_dem0 = abs(dem0)
rect_dem1 = abs(dem1)
rect_dem2 = abs(dem2)
b, a = sp.butter(10, 0.0499, 'low')
demod0 = sp.filtfilt(b, a, rect_dem0)
demod1 = sp.filtfilt(b, a, rect_dem1)
demod2 = sp.filtfilt(b, a, rect_dem2)
plt.subplot(4,1,1)
plt.plot(time,message)
plt.subplot(4,1,2)
plt.plot(time,demod0)
plt.subplot(4,1,3)
plt.plot(time, demod1)
plt.subplot(4,1,4)
plt.plot(time, demod2)
From this open ended project we learned about the effect of noice on a message signal during communication through a channel .we generated a frequency modulated message signal. we also were able to successfully reduce the noise that was added to the signal with the help of a software algorithm that used the library noisereduce , in python. The demodulation of the signals were also done with the help of low pass butterworth filter and all the waveforms were simulated as expected in theory.